/*
 * ErrorDialog.java
 *
 * Created on September 8, 2005, 10:55 AM
 */
package com.bff.bjj.ui;

import com.bff.bjj.ui.component.BJJDialog;
import com.bff.bjj.utils.Resources;
import java.awt.Frame;
import java.awt.Toolkit;
import java.awt.Dimension;

/**
 *
 * @author  Bill
 */
public class ConnectionErrorDialog extends BJJDialog {

    public ConnectionErrorDialog(Frame frame) {
        super(frame, false);

        initComponents();

        Toolkit tk = Toolkit.getDefaultToolkit();
        Dimension d = tk.getScreenSize();
        int heightScreen = d.height / 2;
        int widthScreen = d.width / 2;

        setSize(new Dimension(400, 300));

        setLocation(widthScreen - (int) (getWidth() / 2), heightScreen - (int) (getHeight() / 2));
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        btnPanel = new com.bff.bjj.ui.component.BJJPanel();
        progressBarAttempts = new javax.swing.JProgressBar();
        jPanel2 = new com.bff.bjj.ui.component.BJJPanel();
        btnOK = new com.bff.bjj.ui.component.BJJButton();
        textAreaException = new javax.swing.JTextArea();
        jPanel1 = new com.bff.bjj.ui.component.BJJPanel();
        lblError = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle(getResource(Resources.LABEL_KEY.ERROR_TITLE));

        btnPanel.setLayout(new java.awt.BorderLayout());

        progressBarAttempts.setIndeterminate(true);
        progressBarAttempts.setString(getResource(Resources.LABEL_KEY.ERROR_CONN_RECONNECTNG));
        progressBarAttempts.setStringPainted(true);
        btnPanel.add(progressBarAttempts, java.awt.BorderLayout.NORTH);

        jPanel2.setLayout(new java.awt.GridBagLayout());

        btnOK.setText(Resources.getMessage(Resources.LABEL_KEY.BUTTON_EXIT));
        btnOK.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOKActionPerformed(evt);
            }
        });
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        jPanel2.add(btnOK, gridBagConstraints);

        btnPanel.add(jPanel2, java.awt.BorderLayout.CENTER);

        getContentPane().add(btnPanel, java.awt.BorderLayout.SOUTH);

        textAreaException.setEditable(false);
        textAreaException.setText(getResource(Resources.LABEL_KEY.ERROR_CONN_MESSAGE));
        textAreaException.setBorder(javax.swing.BorderFactory.createEmptyBorder(20, 20, 20, 20));
        getContentPane().add(textAreaException, java.awt.BorderLayout.CENTER);

        lblError.setFont(lblError.getFont().deriveFont(lblError.getFont().getStyle() | java.awt.Font.BOLD, 14));
        lblError.setForeground(java.awt.Color.red);
        lblError.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblError.setText(getResource(Resources.LABEL_KEY.ERROR_CONN_TITLE));
        lblError.setBorder(javax.swing.BorderFactory.createEmptyBorder(10, 10, 10, 10));
        lblError.setFocusable(false);
        lblError.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jPanel1.add(lblError);

        getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
        System.exit(1);
    }//GEN-LAST:event_btnOKActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnOK;
    private javax.swing.JPanel btnPanel;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JLabel lblError;
    private javax.swing.JProgressBar progressBarAttempts;
    private javax.swing.JTextArea textAreaException;
    // End of variables declaration//GEN-END:variables
}
